<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>

<?php 
	$spanClass="span9";
	if( strlen(trim($column_left)) > 0  && strlen(trim($column_right)) > 0 ){
		$spanClass="span6";
	}else if(strlen(trim($column_left)) > 0  || strlen(trim($column_right)) > 0 ){
		$spanClass="span9";
	}else if(strlen(trim($column_left))== 0 && strlen(trim($column_right))== 0){
		$spanClass="span12";
	}else{
		$spanClass="span6";
	}
?>
<div class="<?php echo $spanClass;?>">

<div id="content">

  <?php echo $content_top; ?>
  
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  
  <h1><?php echo $heading_title; ?></h1>
  
  <?php if ($products) { ?>
  <div class="product-filter radius">
    <div class="sort"><b><?php echo $text_sort; ?></b>
      <select onchange="location = this.value;">
        <?php foreach ($sorts as $sorts) { ?>
        <?php if ($sorts['value'] == $sort . '-' . $order) { ?>
        <option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
        <?php } ?>
        <?php } ?>
      </select>
    </div>
    <div class="limit"><b><?php echo $text_limit; ?></b>
      <select onchange="location = this.value;">
        <?php foreach ($limits as $limits) { ?>
        <?php if ($limits['value'] == $limit) { ?>
        <option value="<?php echo $limits['href']; ?>" selected="selected"><?php echo $limits['text']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $limits['href']; ?>"><?php echo $limits['text']; ?></option>
        <?php } ?>
        <?php } ?>
      </select>
    </div>
    <div class="display">
    <b><?php echo $text_display; ?></b> 
    <i class="fa fa-list-ul"></i> <a onclick="display('grid');"><i class="fa fa-th"></i></a>
    </div>
    <div class="product-compare"><a href="<?php echo $compare; ?>" id="compare-total"><?php echo $text_compare; ?></a></div>
  </div>
    
    
   <?php
	//iconProducts
	$iconProducts = explode(',', $this->config->get('icon_product')); 
	$iconProductsSettings=$this->config->get('iconproduct');
	  $styleIconProduct="";
	  if(isset($iconProductsSettings[0]['image_width']) && $iconProductsSettings[0]['image_width'])
		$styleIconProduct .="width:".$iconProductsSettings[0]['image_width']."px;";
	  if(isset($iconProductsSettings[0]['image_height']) && $iconProductsSettings[0]['image_height'])
		$styleIconProduct .="height:".$iconProductsSettings[0]['image_height']."px;";
	  if(isset($iconProductsSettings[0]['image_top']) && $iconProductsSettings[0]['image_top'])
		$styleIconProduct .="top:".$iconProductsSettings[0]['image_top']."px;";
	  if(isset($iconProductsSettings[0]['image_right']) && $iconProductsSettings[0]['image_right'])
		$styleIconProduct .="right:".$iconProductsSettings[0]['image_right']."px;";
	  if(isset($iconProductsSettings[0]['color']) && $iconProductsSettings[0]['color'])
		$styleIconProduct .="background:".$iconProductsSettings[0]['color'].";";
	?>
    
    
  <div class="product-list">
    <?php foreach ($products as $product) { ?>
    <div class="radius">
    
      <?php //iconProducts
          if(in_array($product['product_id'],$iconProducts)){
          	?>
          	<span class="newPadge" style="<?php echo $styleIconProduct; ?>"><?php echo $iconProductsSettings[0]['text']; ?></span>
          	<?php 
          }
       ?>
       
      <!-- Image -->
      <?php if ($product['thumb_swap']) { ?>
      <div class="image">
          <a href="<?php echo $product['href']; ?>">
             <img oversrc="<?php echo $product['thumb_swap']; ?>" src="<?php echo $product['thumb']; ?>" 
             title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" style="border:none"/>
          </a>
      </div>
      <?php } else {?>
      <div class="image">
          <a href="<?php echo $product['href']; ?>">
              <img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" 
              alt="<?php echo $product['name']; ?>" style="border:none"/>
          </a>
      </div>
     <?php } ?>   
     <!-- Name -->  
      <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
      <!-- description -->
      <div class="description"><?php echo $product['description']; ?></div>
      <!-- price -->
      <?php if ($product['price']) { ?>
      <div class="price">
        <?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> 
        <span class="price-new"><?php echo $product['special']; ?></span>
        <span class="sale radius"><?php echo $product['saving']; ?>%</span> 
        <?php } ?>
        <?php if ($product['tax']) { ?>
        <br />
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
        <?php } ?>
      </div>
      <?php } ?>
      <!-- rating -->
      <div class="rating">
      <img src="catalog/view/theme/denzi/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" />
      </div>
      
      <!-- Cart // Wish // Compare -->
      <ul class="cart radius tooltip-title">
        <li><input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" /></li>
        <li><a class="wish" onclick="addToWishList('<?php echo $product['product_id']; ?>');" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>"><i class="fa fa-heart-o"></i></a></li>
        <li><a class="compare" onclick="addToCompare('<?php echo $product['product_id']; ?>');" data-toggle="tooltip" title="<?php echo $button_compare; ?>"><i class="fa fa-bar-chart-o"></i></a></li>
        <li><a href="<?php echo str_replace("/product&","/product/details&",$product['href']); ?>" class="href-fa-eye eye" data-toggle="tooltip" title="<?php echo $quick_view_text; ?>"><i class="fa fa-eye"></i></a></li>
      </ul>
    </div>
    <?php } ?>
  </div>
  
  <div class="pagination"><?php echo $pagination; ?></div>
  <?php } else { ?>
  <div class="content"><?php echo $text_empty; ?></div>
  <?php }?>
  
  <?php echo $content_bottom; ?>
  
  </div><!--/#content-->

</div>
  
<script type="text/javascript"><!--
function display(view) {
	if (view == 'list') {
		$('.product-grid').attr('class', 'product-list');
		
		$('.product-list > div').each(function(index, element) {
			
			html = '<div class="left">';
			var image = $(element).find('.image').html();
			if (image != null) { 
				html += '<div class="image">' + image + '</div>';
			}	
			html += '  <div class="name">' + $(element).find('.name').html() + '</div>';
			html += '  <div class="description">' + $(element).find('.description').html() + '</div>';
			html += '</div>';
			
			
			html  += '<div class="right">';
			var price = $(element).find('.price').html();
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
			var rating = $(element).find('.rating').html();
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
			html += '<ul class="cart radius tooltip-title">' + $(element).find('.cart').html() + '</ul>';
			html += '</div>';	
						
			$(element).html(html);
		});		
		
		$('.display').html('<b><?php echo $text_display; ?></b> <i class="fa fa-list-ul"></i> <a onclick="display(\'grid\');"><i class="fa fa-th"></i></a>');
		
		$.totalStorage('display', 'list'); 
	} else {
		$('.product-list').attr('class', 'product-grid');
		
		$('.product-grid > div').each(function(index, element) {
			html = '';
			
			var image = $(element).find('.image').html();
			if (image != null) {
				html += '<div class="image">' + image + '</div>';
			}
			html += '<div class="name">' + $(element).find('.name').html() + '</div>';
			html += '<div class="description">' + $(element).find('.description').html() + '</div>';
			var price = $(element).find('.price').html();
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
			var rating = $(element).find('.rating').html();
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
			html += '<ul class="cart radius tooltip-title">' + $(element).find('.cart').html() + '</ul>';
			$(element).html(html);
		});	
					
		$('.display').html('<b><?php echo $text_display; ?></b> <a onclick="display(\'list\');"><i class="fa fa-list-ul"></i></a> <i class="fa fa-th"></i>');
		
		$.totalStorage('display', 'grid');
	}
	if(swap_product_image==1)// check for swap_product_image
		SimpleSwapSetup();
	
	setTimeout(function(){
		$('.tooltip-title').tooltip({
		  selector: "a[data-toggle=tooltip], li[data-toggle=tooltip]"
		});
	},5);
}

view = $.totalStorage('display');

if (view) {
	display(view);
} else {
	display('list');
}

function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}
function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
	var oversrc = x[i].getAttribute("oversrc");
	if (!oversrc) continue;
	x[i].oversrc_img = new Image();
	x[i].oversrc_img.src=oversrc;
	x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
	x[i].onmouseout = new Function("SimpleSwap(this);");
	x[i].setAttribute("origsrc",x[i].src);
  }
}
//--></script> 
<?php echo $footer; ?>